<template>
    <view :style="'direction:' + $t('dir')" :class="$t('dir') == 'rtl' ? 'rtl' : 'ltr'">
        <navbar :title="$t('wodeguanzhu')" />

        <view class="main">
            <view class="d-flex flex-wrap items-center justify-between pa-md pt-xs">
                <house-row v-for="(item, i) in houses" :item="item" :key="i" />
            </view>
            <u-empty v-if="!houses || houses.length == 0" mode="list" icon="/static/images/empty.png" :text="$t('no_content')" style="padding-top: 250rpx" />
        </view>
    </view>
</template>
<script>
export default {
    data() {
        return {
            houses: [],
            current_page: 1,
            last_page: 1,
        }
    },
    onLoad() {
        this.getList()
    },
    onShow() {},
    onPullDownRefresh() {
        uni.stopPullDownRefresh()
    },
    onReachBottom() {
        if (this.current_page < this.last_page) {
            this.current_page += 1
            this.getList()
        }
    },
    methods: {
        getList() {
            uni.showLoading({
                title: '',
            })
            this.$uniapi('/my-follow', { page: this.current_page, pageSize: 10 })
                .then((res) => {
                    uni.hideLoading()
                    if (res.code == 0) {
                        let resData = res.data
                        if (page == 1) this.houses = resData.data
                        else this.houses.push(...resData.data)
                        this.current_page = resData.current_page
                        this.last_page = resData.last_page
                    }
                })
                .catch((err) => {
                    uni.hideLoading()
                })
        },
    },
}
</script>
